package base;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by cch on 2016/6/20.
 */
//缓存数据
public class SharedPreferencesutils{
    private static SharedPreferences sp;
    private static String SP_NAME = "config";//静态变量一般要大些

//    SharedPreferences sp = ct.getSharedPreferences("config", 0);
//    SharedPreferences.Editor edit = sp.edit();
//    edit.putString("xxxxx",hb.getTitle());
//    edit.commit();

    public static void saveString(Context ct,String key,String value){
        if (sp == null)
            sp = ct.getSharedPreferences(SP_NAME, 0);
            sp.edit().putString(key,value).commit();
    }
    public static String getString(Context ct,String key){
        if (sp == null)
            sp = ct.getSharedPreferences(SP_NAME, 0);
        return sp.getString(key,"");
    }
}
